<template name="swiper">
	<view class="wrap">
		<view v-if="show">
			<u-swiper
				:list="list"
				img-mode="scaleToFill"
				:height="400"
				@click="sendClickIndex"
				name="swiperImagesUrl"
			></u-swiper>
		</view>
		<view class="errSwiper" v-else>
			<image
				src="../../static/show.gif"
				mode=""
				style="width: 100%;"
			></image>
		</view>
	</view>
</template>

<script>
export default {
	name: 'swiper',
	data() {
		return {
			list: [],
			show: false
		};
	},
	methods: {
		// 向父组件传递点击图片的index
		sendClickIndex(index) {
			this.$emit('clickSwiper', index);
		}
	},
	watch: {
		// 监视父组件传来的图片路径数组
		swiperList(newvalue, oldvalue) {
			this.list = newvalue;
			this.show = true;
		}
	},
	beforeDestroy() {
		this.$off('clickSwiper');
	},
	props: ['swiperList']
};
</script>

<style lang="scss" scoped>
.wrap {
	height: 100%;
}
</style>
